package com.sanben.company.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sanben.common.web.domain.Result;
import com.sanben.company.data.dto.CompanyTeamCaseDto;
import com.sanben.company.data.req.CompanyTeamCaseReq;
import com.sanben.company.data.vo.CompanyTeamCaseVo;
import com.sanben.company.entity.CompanyTeamCase;
import com.sanben.company.service.ICompanyTeamCaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author cyh
 * @description: 公司团队案例表 控制器
 * @date: 2020-08-11
 */
@RestController
@RequestMapping("/companyTeamCase")
@Api(tags = "公司团队案例表相关接口")
public class CompanyTeamCaseController {

    @Autowired
	private ICompanyTeamCaseService companyTeamCaseService;

	@GetMapping("/page")
	@ApiOperation(value = "产品案例-分页", notes = "传入companyTeamCaseReq")
	public Result<IPage<CompanyTeamCaseVo>> page(CompanyTeamCaseReq req) {
		IPage<CompanyTeamCaseVo> pages = companyTeamCaseService.page(req);
		return Result.data(pages);
	}

	@GetMapping("/list")
	@ApiOperation(value = "首页-产品案例")
	public Result<List<CompanyTeamCase>> getHomeList() {
		List<CompanyTeamCase> list = companyTeamCaseService.getHomeList();
		return Result.data(list);
	}

	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入id")
	public Result<CompanyTeamCase> detail(@PathVariable Integer id) {
	    CompanyTeamCase detail = companyTeamCaseService.detail(id);
		return Result.data(detail);
	}

	@PostMapping
	@ApiOperation(value = "新增", notes = "传入companyTeamCase")
	public Result save(@RequestBody CompanyTeamCaseDto dto) {
		return Result.data(companyTeamCaseService.save(dto));
	}

	@PutMapping
	@ApiOperation(value = "修改", notes = "传入companyTeamCase")
	public Result update(@RequestBody CompanyTeamCaseDto dto) {
		return Result.data(companyTeamCaseService.updateById(dto));
	}

	@DeleteMapping("/{ids}")
	@ApiOperation(value = "逻辑删除", notes = "传入ids")
	public Result remove(@PathVariable List<Integer> ids) {
		return Result.data(companyTeamCaseService.deleteLogic(ids));
	}

}
